package com.hotel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hotel.entity.AddressBook;
import com.hotel.mapper.AddressBookMapper;
import com.hotel.service.AddressBookService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hotel.vo.AddressBookVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 地址管理 服务实现类
 * </p>
 *
 * @author Lin
 * @since 2022-06-16
 */
@Service
public class AddressBookServiceImp extends ServiceImpl<AddressBookMapper, AddressBook> implements AddressBookService {

    @Override
    public AddressBookVO editAddressBook(String id) {
        QueryWrapper<AddressBook> wrapper = new QueryWrapper<>();
        wrapper.eq("id",id);
        AddressBook addressBook = this.baseMapper.selectOne(wrapper);
        AddressBookVO addressBookVO = new AddressBookVO();
        BeanUtils.copyProperties(addressBook,addressBookVO);
        return addressBookVO;
    }

    @Override
    public int updateAddressBook(AddressBookVO addressBookVO) {
        AddressBook addressBook = new AddressBook();
        BeanUtils.copyProperties(addressBookVO,addressBook);
        return this.baseMapper.updateById(addressBook);
    }
}
